﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Linkmeme.Controllers
{
    public class SourceController : BaseController
    {
        public void Index()
        {
            // Add action logic here
        }

       // [CacheFilter(Duration = 60)]
        public void View(string sourceType, int providerId, string providerUserName)
        {
            switch (sourceType.ToLower())
            {
                case "photo":
                    ViewData["data"] = ViewDataBuilder<Picture>.BuildForView(providerId, providerUserName);
                    break;
                case "blog":
                    ViewData["data"] = ViewDataBuilder<Blog>.BuildForView(providerId, providerUserName);
                    break;
                case "bookmark":
                    ViewData["data"] = ViewDataBuilder<Bookmark>.BuildForView(providerId, providerUserName);
                    break;
                case "status":
                    ViewData["data"] = ViewDataBuilder<Status>.BuildForView(providerId, providerUserName);
                    break;
                default:
                    break;
            }
            RenderView("Index");
        }

     //   [CacheFilter]
        public void ViewAll(string sourceType, string groupBy)
        {

            switch (sourceType.ToLower())
            {
                case "photo":
                    ViewData["data"] = ViewDataBuilder<Picture>.BuildForViewAll(CurrentUserId, groupBy);
                    break;
                case "blog":
                    ViewData["data"] = ViewDataBuilder<Blog>.BuildForViewAll(CurrentUserId, groupBy);
                    break;
                case "bookmark":
                    ViewData["data"] = ViewDataBuilder<Bookmark>.BuildForViewAll(CurrentUserId, groupBy);
                    break;
                case "status":
                    ViewData["data"] = ViewDataBuilder<Status>.BuildForViewAll(CurrentUserId, groupBy);
                    break;
                default:
                    break;
            }

            if (IsUserAuthenticated)
            {
                ViewData["friends"] = (new Linkmeme.Models.LinkmemeDataContext()).Users.Single(uf => uf.UserId == CurrentUserId).Friends.ToList();
            }

            RenderView("ViewAll");

        }
    }
}
